using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class mapControl : MonoBehaviour
{
    public GameObject springMap;
    public GameObject summerMap;
    public GameObject fallMap;
    public GameObject winterMap;
    public GameObject timeSystem;

    private GameObject isSpring;
    private GameObject isSummer;
    private GameObject isFall;
    private GameObject isWinter;

    void Update()
    {
        ChangeSeasonMap();
    }
    void ChangeSeasonMap()
    {
        TimeController timeController = timeSystem.GetComponent<TimeController>();
        springMap = Resources.Load<GameObject>("Prefabs/map/Spring");
        summerMap = Resources.Load<GameObject>("Prefabs/map/Summer");
        fallMap = Resources.Load<GameObject>("Prefabs/map/Fall");
        winterMap = Resources.Load<GameObject>("Prefabs/map/Winter");

        isSpring = GameObject.FindGameObjectWithTag("springMap");
        isSummer = GameObject.FindGameObjectWithTag("summerMap");
        isFall = GameObject.FindGameObjectWithTag("fallMap");
        isWinter = GameObject.FindGameObjectWithTag("winterMap");


        if (timeController.seasonType == 1)
        {
            if (isWinter)
            {
                Destroy(isWinter);
            }
    
            if (!isSpring)
            {
                Instantiate(springMap);
            }

        }

        if (timeController.seasonType == 2)
        {
            if (isSpring)
            {
                Destroy(isSpring);
            }
 
            if (!isSummer)
            {
                Instantiate(summerMap);
            }
        }
        if (timeController.seasonType == 3)
        {
            if (isSummer)
            {
                Destroy(isSummer);
            }
         
            if (!isFall)
            {
                Instantiate(fallMap);
            }
        }
        if (timeController.seasonType == 4)
        {
            if (isFall)
            {
                Destroy(isFall);
            }
    
            if (!isWinter)
            {
                Instantiate(winterMap);
            }
        }

        // Update is called once per frame

    }
}
